include( "shared.lua" )

ENT.EffectInterval = 10

function ENT:Draw()
	local size = self:GetNWInt ("dmg", 75)
	
	if !self.LastPos then self.LastPos = self:GetPos() end
	
	local dist = (self:GetPos() - self.LastPos):Length()
	
	if dist > self.EffectInterval then
		local pos = self:GetPos()
		local dir = (self.LastPos - self:GetPos()):GetNormal()
		self.em = ParticleEmitter (pos)
		
		for i=1, math.floor (dist / self.EffectInterval) do
			pos = pos + dir * -self.EffectInterval
			local part = self.em:Add("sprites/light_glow02_add",pos)
			if !part then return end
			part:SetColor(0,255,0)
			part:SetVelocity(Vector(math.random(-1,1),math.random(-1,1),math.random(-1,1)):GetNormal() * size/10)
			part:SetDieTime(0.5)
			part:SetLifeTime(0)
			part:SetStartSize(size/10)
			part:SetEndSize(0) 
			self.LastPos = pos
		end
		
		self.em:Finish()
	end
end
